function myfft(y)
Fs = length(y);                    % Sampling frequency
T = 1/Fs;                     % Sample time
L = length(y);                     % Length of signal
t = (0:L-1)*T;                % Time vector
% Sum of a 50 Hz sinusoid and a 120 Hz sinusoid
subplot(2,1,1)
plot(Fs*t,y)
title('Signal')
xlabel('time (milliseconds)')


NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(y,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);

subplot(2,1,2)
% Plot single-sided amplitude spectrum.
plot(f,2*abs(Y(1:NFFT/2+1)),'.') 
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')

figure
plot(ifft(Y))